import { BrowserWindow } from 'electron';
import  WindowPoolManager, {getOpenUrl} from './window';
import type {WindowPoolOptions} from './window';

export const initWindowManager = (): WindowPoolManager => {
  return WindowPoolManager.getInstance(2);
}


export const openWindow = (windowOptions: WindowPoolOptions): BrowserWindow => {
  const windowManager = initWindowManager();
  const newUrl = getOpenUrl(windowOptions.url);
  const win = windowManager.openWindow({
    ...windowOptions,
    url: newUrl,
  });
  return win;
}

export {
  getOpenUrl,
}
